package com.zk.controller;

import com.zk.entity.Evaluation;
import com.zk.service.IAllEvaluationService;
import com.zk.vo.EvaluationVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author fmy
 * show evaluation list,insert evaluation into db
 * URL:http://ip/evaluation?current=1&&size=2&&productId=0
 */
//@ApiParam(required = "“是否必须参数”", name = "“参数名称”", value = "“参数具体描述”")
//@ApiOperation(value = “接口说明”, httpMethod = “接口请求方式”, response = “接口返回参数类型”, notes = “接口发布说明”；其他参数可参考源码；

@ApiOperation(value = "根据productId查询评价信息", httpMethod = "Get",  notes = "差中好评对应0,1,2")

@RestController
public class EvaluationController {
    @Autowired
    private IAllEvaluationService iAllEvaluationService;
    //@ResponseBody
    /*
    public ResponseEntity<List<Evaluation>> getAllEvaluation(){
        List<Evaluation> all_list_evaluation=evaluationMapper.selectList(null);
        ResponseEntity<List<Evaluation>> resentity =  new ResponseEntity<List<Evaluation>>(all_list_evaluation,HttpStatus.OK);
        return resentity;
    }  */
    @RequestMapping(value = "/evaluation",method = RequestMethod.GET)///{orderid}/evaluation
    public EvaluationVo getEvaluationListPageByProductId(
            @ApiParam(required = false, name = "current", value = "分页当前第几页,default=1")
            @RequestParam(value = "current",required = false,defaultValue = "1")Integer current,
            @ApiParam(required = false, name = "current", value = "分页每页条数,default=10")
         @RequestParam(value = "size",required = false,defaultValue = "10") Integer size,
            @ApiParam(required = true, name = "productId", value = "商品Id,测试productId=0")
    @RequestParam(value = "productId",required = false,defaultValue = "0") Integer productId){
        return iAllEvaluationService.getEvaluationListPageByProductId(current,size,productId);
    }
}
